package com.fortune.controller.acl;

import com.fortune.common.acl.JsonData;
import com.fortune.service.acl.MRoleService;
import com.fortune.service.acl.MTreeService;
import com.google.common.collect.Maps;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.Map;

//@Controller("AclMUserController")
@RequestMapping("/m/user")
public class MUserController {

    @Resource
    private MTreeService sysTreeService;
    @Resource
    private MRoleService sysRoleService;


    @RequestMapping("/acls.json")
    @ResponseBody
    public JsonData acls(@RequestParam("userId") int userId) {
        Map<String, Object> map = Maps.newHashMap();
        map.put("acls", sysTreeService.userAclTree(userId));
        map.put("roles", sysRoleService.getRoleListByUserId(userId));
        return JsonData.success(map);
    }
}
